package com.bsoft.ecommerce.controller;

import com.bsoft.ecommerce.service.NacosClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: e-commerce-springclound
 * @description:
 * @author: hdh
 * @create: 2022:06:07 17:50
 */

@RestController
@Slf4j
@RequestMapping("/nacos-client")
public class NacosClientController {
    private final NacosClientService nacosClientService;

    public NacosClientController(NacosClientService nacosClientService) {
        this.nacosClientService = nacosClientService;
    }

    @GetMapping("/service-instance")
    public List<ServiceInstance> logINfo(@RequestParam(defaultValue = "e-commerce-nacos-client") String serviceId) {
        log.info("------------" + serviceId);
        return nacosClientService.getList(serviceId);
    }
}
